home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gekikoh Dennoh Club 5
/
Gekikoh Dennoh Club Vol. 5 (Japan).7z
/
Gekikoh Dennoh Club Vol. 5 (Japan) (Track 01).bin
/
internet
/
aish
/
msmtp121.lzh
/
msmtp.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-12-23
|
3KB
|
138 lines
/* Copyright 1996 H.Ogasawara */
#include "stdio.h"
#include "network.h"
#include "sys/socket.h"
#include "arpa/telnet.h"
#include "sys_doslib.h"
#include "microfio.h"
#include "microstr.h"
#include "cinet.h"
#define MAXLINE (1024*4)
static int Port= 0;
static char FFm,
From[100],
To[100],
Domain[100],
Host[100];
static m_file fm;
static char _LogName[80];
static void
_message( char *ptr )
{
PRINT( ptr );
}
static void
_logclose()
{
if( FFm ){
Mclose( &fm );
FFm= 0;
}
}
static
_logopen()
{
if( FFm )
_logclose();
if( !(FFm= Mopen( &fm, _LogName )) )
_message( "âtâ@âCâïé¬éáéΦé▄é╣é±\r\n" );
return FFm;
}
static void
_local_error( msg )
char *msg;
{
_message( "smtp: " );
_message( msg );
_message( "\r\n" );
_logclose();
EXIT2( 0 );
}
static void
smtp()
{
char lbuf[MAXLINE];
if( !TnScriptExec( NULL, NULL, -1, 1 ) ) return;
if( !TnRerrExec( "HELO", Domain, -1, 1 ) ) return;
s_strcpy( s_strcpy( lbuf, "from:" ), From );
if( !TnRerrExec( "MAIL", lbuf, -1, 1 ) ) return;
s_strcpy( s_strcpy( lbuf, "to:" ), To );
if( !TnRerrExec( "RCPT", lbuf, -1, 1 ) ) return;
if( _logopen() ){
int len;
_message( "æùÉMÆå " );
_message( To );
_message( "\r\n" );
if( !TnRerrExec( "DATA", NULL, -1, 1 ) ) return;
for(; (len= Mgets( &fm, lbuf, MAXLINE )) >= 0 ;){
lbuf[len]= '\r';
lbuf[len+1]= '\n';
lbuf[len+2]= '\0';
TnSendLine( lbuf );
}
if( !TnEofSend() ) return;
_logclose();
_message( "æùÉMè«ù╣\r\n" );
}
TnScriptExec( "QUIT", NULL, -1, 1 );
}
main( argc, argv )
char **argv;
{
TnSetVect( TNV_MESSAGE, _message );
TnSetVect( TNV_ERROR, _local_error );
_message( "MicroSmtp v1.21 1996 Ogasawara Hiroyuki(COR.)\r\n" );
*_LogName= '\0';
if( _get_version() < 0 ){
_local_error( "inetd" );
return;
}
TnGetEnv( Host, "SMTPSERVER" );
TnGetEnv( Domain, "MAILDOMAIN" );
TnGetEnv( From, "MAILFROM" );
for(; argv++,--argc ; ){
if( **argv == '-' ){
switch( argv[0][1] ){
case 'f':
s_strcpy( From, *argv+2 );
break;
case 't':
s_strcpy( To, *argv+2 );
break;
case 'h':
s_strcpy( Host, *argv+2 );
break;
case 'd':
s_strcpy( Domain, *argv+2 );
break;
case 'P':
Port= n_numstr( *argv+2 );
break;
default:
goto _usage;
}
}else
s_strcpy( _LogName, *argv );
}
if( *_LogName ){
TnOpen( Host, Port, "smtp" );
smtp();
_logclose();
}else{
_usage:
_message( "usage: msmtp [-hHOST] [-dDOMAIN] [-fFROM] [-Pp] -tTO file\r\n");
return 1;
}
return 0;
}